<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="root"></div>


  <script crossorigin src="https://unpkg.com/react@18.3.1/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@18.3.1/umd/react-dom.development.js"></script>
  <script crossorigin src="https://unpkg.com/babel-standalone@6.26.0/babel.min.js"></script>

  <script type="text/babel">

    class App extends React.Component {
      constructor() {
        super()
        this.state = {
          counter: 0
        }
        // this.handleChangeCounter1 = this.handleChangeCounter1.bind(this)
      }
      handleChangeCounter1(event) {
        console.log(event)
      }
      handleChangeCounter2 = (event, arg1, arg2) => {
        console.log(event, arg1, arg2)
      }
      render() {
        const { counter } = this.state
        return (
          <div>
            <h2>counter: { counter }</h2>
            {/* event参数传递方式1 */}
            <button onClick={this.handleChangeCounter2.bind(this, '2', '4')}>按钮1</button>
            {/* event参数传递方式2（推荐）使用箭头函数传参 */}
            <button onClick={(event) => this.handleChangeCounter2(event, '1', '2')}>按钮2</button>
          </div>
        )
      }
    }
    
    const root = ReactDOM.createRoot(document.querySelector('#root'))
    root.render(<App/>)
  </script>
</body>
</html>